<?php

$query = mysql_query("SELECT COUNT(`aanbiedingnummer`) as 'count' FROM `aanbiedingen` WHERE date(now()) BETWEEN `begindatum` AND `einddatum`",$server);
while($row = mysql_fetch_array($query)){
if($row[count]>0){

		$query = mysql_query("
		SELECT aanbiedingen.productnummer, productnaam, description, image, cat1, cat2, cat3, prijs, aanbiedingsprijs 
		FROM aanbiedingen, producten, productprijs
		WHERE date(now()) BETWEEN `begindatum` AND `einddatum` 
		AND producten.productnummer=aanbiedingen.productnummer
		AND producten.productnummer=productprijs.productnummer
		ORDER BY RAND()
		LIMIT 6;
		",$server);

		$temp=0;

		echo "<center><table border='1' cellspacing='0' cellpadding='0' BORDERCOLORDARK='white'>";

		while($row = mysql_fetch_array($query)){
			
			if ($temp==0){
			echo "<tr><td width='40%'>";
			}
			
			else {
			echo "<td width='40%'>";
			}
			echo "
			<font size='1'><a href='http://localhost/producten.php?cat1=$row[cat1]'>$row[cat1]</a> / <a href='http://localhost/producten.php?cat2=$row[cat2]'>$row[cat2]</a></font> 
			<BR>
			<H4><a href='http://localhost/product.php?id=$row[productnummer]'>$row[productnaam]</a></H4> 
			<BR>
			<table border='0'>
			<tr>
			<td>
			<img src='images/producten/thumb_$row[image]'></img>
			</td>
			<td>$row[description]</td>
			</tr>
			</table>";
			$prijs = $row[prijs]/100;
			echo "<H6>&euro; <S>$prijs</S></H6>";
			$prijs = $row[aanbiedingsprijs]/100;
			echo "<H4><font color='red'>&euro; $prijs </H4></td>";
			
			if ($temp==0){
			$temp=1;
			}
			
			else {
			echo "</tr>";
			$temp=0;
			}
			
			}

			echo "</table>";
			
}
else
echo "Er zijn op dit moment helaas geen aanbiedingen.";
}

